package net.dodoman.annotation;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.junit.Test;

public class TempTest {

	public static void main(String... args) {
		for (int i = 0; i < args.length; i++) {
			for (int j = 0; j < 4; j++) {
				if (j == 2) {
					break;
				}
				System.out.println("b");
			}
			System.out.println("a");
		}
	}

	// @Test
	// @MyTag(name = "aa", value = "da")
	public void test1() {
		List<String> list1 = new ArrayList<String>();
		list1.add("aaa");
		List<String> list2 = new ArrayList<String>();
		list2.add("aab");
		Collections.addAll(list1, new String[] { "1" });
		getAnnotion();
	}

	/* 通过反射取得到该方法的所有注解 */

	private void getAnnotion() {
		try {
			System.out.println(this.getClass().getMethod("test1"));
			Annotation[] annotation = this.getClass().getMethod("test1")
					.getAnnotations();// 取得注解所在方法,从而得到所有注解
			for (Annotation tag : annotation) {
				if (MethodAnnotation.class.isAssignableFrom(tag.annotationType())) { // 只输出是MyTag注解的内容
					System.out.println("Tag is:" + tag);
					System.out.println("tag.name()" + ((MethodAnnotation) tag).name());
					System.out.println("tag.age()" + ((MethodAnnotation) tag).value());
				}
			}
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		}
	}

	@Test
	public void testDate() {
		Calendar c = Calendar.getInstance();
		c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH),
				c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.HOUR_OF_DAY),
				c.get(Calendar.MINUTE));
		Date date = c.getTime();
		System.out.println(date);
		System.out.println(c.get(Calendar.DAY_OF_MONTH));
	}
}